<?php

/**
 * sfWidgetFormSchemaFormatterBackend.
 *
 * @package    flexiwik
 * @subpackage widget
 * @author     Jonathan Olger Nieto Lajo <jonathan_nieto@hotmail.com>
 */
class sfWidgetFormSchemaFormatterBackend extends sfWidgetFormSchemaFormatter
{
  protected
    $rowFormat                 = "<tr>\n  
                                    <td class=\"label popup_dialog_body_left_padded\" width=\"30%\" class=\"label\"><span%class%>%label%</span></td>\n  
                                    <td class=\"value popup_dialog_body_right_padded\">%field%%help%%hidden_fields%</td>\n
                                  </tr>\n",
    $errorRowFormat            = "<tr><td class=\"help error_msg clean_error_background\" colspan=\"2\">\n%errors%</td></tr>\n",
    //$errorRowFormat            = "%errors%",
    $helpFormat                = '<br />%help%',
    $errorListFormatInARow     = "<ul class=\"error_list\">\n%errors%  </ul>\n",
    $namedErrorRowFormatInARow = "<li>%error%</li>\n",
    $decoratorFormat           = "%content%";
    //$decoratorFormat           = "<table id=\"crud_form\">\n  %content%</table>";

  public function formatRowExt($label, $field, $errors = array(), $help = '', $hiddenFields = null, $name)
  {
    return strtr
           (
             $this->getRowFormat(),
             array
             (
               '%class%'         => strpos($label, '*') ? ' class="required"' : '',
               '%label%'         => $label,
               '%field%'         => has_slot($name) ? get_slot($name) : $field,
               '%help%'          => $this->formatHelp($help),
               '%hidden_fields%' => is_null($hiddenFields) ? '%hidden_fields%' : $hiddenFields,
             )
           );
  }
}
